package constant.milk.cashbook.database;

import java.util.HashMap;

import constant.milk.cashbook.util.MilkUtil;


import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;

public class DbUpdateQuery
{
	private Context context;
	private DbAdapter db;
	
	public DbUpdateQuery(Context context, DbAdapter db)
	{
		this.context = context;
		this.db = db;
	}
	
	public void setBeginTansaction() throws Exception
	{
		db.beginTansaction(context);
	}
	
	public void setSuccessful() throws Exception
	{
		db.setTransactionSuccessful();
	}
	
	public void setEndTansaction() throws Exception
	{
		db.endTransaction(context);
	}
	
	/**
	 * 현금 테이블에 데이터를 수정한다.
	 * @param context
	 * @param map
	 */
	public void setRealMoneyUpdate(HashMap<String, String> map, String id) throws Exception
	{
		String [] whereArgs = new String[]{id};
		
		db.update(context, map, TableName.REAL_MONEY, "id = ?", whereArgs);
	}
	
	/**
	 * 통장 테이블에 데이터를 수정한다.
	 * @param context
	 * @param map
	 */
	public void setBankBookUpdate(HashMap<String, String> map, String id) throws Exception
	{
		String [] whereArgs = new String[]{id};
		
		db.update(context, map, TableName.BANK_BOOK, "id = ?", whereArgs);
	}
	
	/**
	 * 체크카드 테이블에 데이터를 수정한다.
	 * @param context
	 * @param map
	 */
	public void setCheckCardUpdate(HashMap<String, String> map, String id) throws Exception
	{
		String [] whereArgs = new String[]{id};
		
		db.update(context, map, TableName.CHECK_CARD, "id = ?", whereArgs);
	}
	
	/**
	 * 신용카드 테이블에 데이터를 수정한다.
	 * @param context
	 * @param map
	 */
	public void setCreditCardUpdate(HashMap<String, String> map, String id) throws Exception
	{
		String [] whereArgs = new String[]{id};
		
		db.update(context, map, TableName.CREDIT_CARD, "id = ?", whereArgs);
	}
	
	/**
	 * 핸드폰 테이블에 데이터를 수정한다.
	 * @param context
	 * @param map
	 */
	public void setPhoneUpdate(HashMap<String, String> map, String id) throws Exception
	{
		String [] whereArgs = new String[]{id};
		
		db.update(context, map, TableName.PHONE, "id = ?", whereArgs);
	}
	
	/**
	 * 상품권 테이블에 데이터를 수정한다.
	 * @param context
	 * @param map
	 */
	public void setGiftCardUpdate(HashMap<String, String> map, String id) throws Exception
	{
		String [] whereArgs = new String[]{id};
		
		db.update(context, map, TableName.GIFT_CARD, "id = ?", whereArgs);
	}
	
	public void setInOutUpdate(HashMap<String, String> map, String id) throws Exception
	{
		String [] whereArgs = new String[]{id};
		
		db.update(context, map, TableName.IN_OUT, "id = ?", whereArgs);
	}
	
	public void setInOutUpdateLinkId(HashMap<String, String> map, String id) throws Exception
	{
		String [] whereArgs = new String[]{id};
		
		db.update(context, map, TableName.IN_OUT, "linkid = ?", whereArgs);
	}
	
	public void setCategoryMainUpdate(HashMap<String, String> map, String id) throws Exception
	{
		String [] whereArgs = new String[]{id};
		
		db.update(context, map, TableName.CATEGORY_MAIN, "id = ?", whereArgs);
	}
	
	public void setCategorySubUpdate(HashMap<String, String> map, String id) throws Exception
	{
		String [] whereArgs = new String[]{id};
		
		db.update(context, map, TableName.CATEGORY_SUB, "id = ?", whereArgs);
	}
	
	public void setAutoMainUpdate(HashMap<String, String> map, String id) throws Exception
	{
		String [] whereArgs = new String[]{id};
		
		db.update(context, map, TableName.AUTO_MAIN, "id = ?", whereArgs);
	}
	
	public void setSmsUpdate(HashMap<String, String> map, String id) throws Exception
	{
		String [] whereArgs = new String[]{id};
		
		db.update(context, map, TableName.SMS, "id = ?", whereArgs);
	}
	
	public void setHalbuUpdate(HashMap<String, String> map, String id) throws Exception
	{
		String [] whereArgs = new String[]{id};
		
		db.update(context, map, TableName.HALBU, "id = ?", whereArgs);
	}
	
	public void setBudgetUpdate(HashMap<String, String> map, String id) throws Exception
	{
		String [] whereArgs = new String[]{id};
		
		db.update(context, map, TableName.BUDGET, "id = ?", whereArgs);
	}
	
	public void setMainSettingUpdate(HashMap<String, String> map, String id) throws Exception
	{
		String [] whereArgs = new String[]{id};
		
		db.update(context, map, TableName.MAIN_SETTING, "id = ?", whereArgs);
	}
	
	public void setWidgetSettingUpdate(HashMap<String, String> map, String id) throws Exception
	{
		String [] whereArgs = new String[]{id};
		
		db.update(context, map, TableName.WIDGET_SETTING, "id = ?", whereArgs);
	}
}
